package com.surekam.mnai.webservice.server;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.surekam.mnai.model.MNAIUser;
import com.surekam.mnai.service.UserLoginService;
import com.surekam.mnai.webservice.WsConstants;

@Component
@Path("/login")
public class LoginService {

	@Autowired
	private UserLoginService userLoginService;
	
	@GET
	@Path("/loginByUserNumberAndPassword")
	@Produces({ MediaType.APPLICATION_JSON + WsConstants.WEB_CHARSET })
	public MNAIUser loginByUserNumberAndPassword(@Context UriInfo info){
		
		String usernumber = info.getQueryParameters().getFirst("usernumber");
		String password = info.getQueryParameters().getFirst("password");
		
		return userLoginService.loginByUserNumberAndPassword(usernumber,password);
	}
	
}
